// packageA/pages/operate/index/index.js
let App = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    show: false,
    dayshow: false,
    getHomeDatainf:{},
    bottom_data:{},
    top_data:{},
    middle_data:{},
    list:[
      {
        title:'首页',
        icon:'/packageA/images/1.png',
        selected_icon:'/packageA/images/1_selected.png',
        path:'../../operate/index/index'
      },
      {
        title:'楼盘',
        icon:'/packageA/images/4.png',
        selected_icon:'/packageA/images/4_selected.png',
        path:'../../operate/floor/floor'
      },
      {
        title:'个人中心',
        icon:'/packageA/images/5.png',
        selected_icon:'/packageA/images/5_selected.png',
        path:'../../operate/account-center/account-center'
      },
    ],
    actions: [
      {
        name: '全部',
        value: '',
      },
      {
        name: '今日',
        value: 'today',
      },
      {
        name: '昨日',
        value: 'yesterday',
      },
      {
        name: '本周',
        value: 'this_weeky',
      },
      {
        name: '本月',
        value: 'this_month',
      },
      {
        name: '上月',
        value: 'last_month',
      },
    ],
    text:'全部',
    datetime:''
  },
//日历
  onDisplay() {
    this.setData({ show: true });
  },
  onClose() {
    this.setData({ show: false });
    this.setData({ dayshow: false });
    this.getHomeData(this.data.value)
  },
//今日选择
onSelect(event) {
  console.log(event.detail);
  this.setData({
    text:event.detail.name,
    value:event.detail.value,
  })
},
dayshowbtn(){
  this.setData({ dayshow: true });
},
detaillist(){
  wx.navigateTo({
    url: '/packageA/pages/operate/demonstration/demonstration-list',
  })
},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },

  onDayClick(event){
    this.setData({ 
      show: false,
      datetime:event.detail.id
     });
    console.log(event.detail)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let token = wx.getStorageSync('token')
    let role_id = wx.getStorageSync('role_id')
    if (token == null || token == undefined || token == '') {
      wx.redirectTo({
        url: '../login/login',
      })
    }
    this.getHomeData();
  },


   /**
 * 获取列表数据
 */
getHomeData() {
  let _this = this
  App._post_form('Business/getHomeData', {
    date_type: _this.data.value,
  }, function (result) {
    _this.setData({
      getHomeDatainf: result.data,
      top_data:result.data.top_data,
      middle_data:result.data.middle_data,
      bottom_data:result.data.bottom_data
    })
    console.log(_this.data.myTopDatainf)
  });
},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.getHomeData();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})